<script>
import BaseUrl from "@/http/request/BaseUrl";
import TokenAxios from "@/http/request/TokenAxios";

export default {
  data(){
    return{
      // 当前每页显示多少条数据
      pageSize: 6,
      noteContent: '',
      resourcesType: '',
      showImagedetail: false,
      openUpdateAduitByIds:false,
      url:[],
      //分页相关数据
      currentPage: this.$router.currentRoute.query.page ? parseInt(this.$router.currentRoute.query.page) : 1,
      tableData: [],
      total: 0,
    }
  },
  methods:{
    //  查看图片详情
    selectImagedetail(note) {

      this.showImagedetail = true;
      this.noteContent = note.noteContent;
      console.log(note.noteContent);
      let urls = BaseUrl.ADMIN_CONTENT + "/admin/note/" + note.noteId + "/picture";
      TokenAxios.get(urls).then((response) => {
        let JsonResult = response.data;
        if (JsonResult.state == 20000) {
          this.url = JsonResult.data; // 将返回的数据赋值给picUrl数组
          console.log(JsonResult.data)
        } else {
          // 处理状态不为 20000 的情况
        }
      }).catch((error) => {
        // 处理请求错误
        console.error(error);
      });
    },
// 切换分页
    handleCurrentChange(page) {
      // 修改当前页码时，使用 $router.push 而不是 $router.replace，保留浏览器的历史记录
      this.$router.replace('?page=' + page);
      this.loadUserList(page); // 将当前页码传递给 loadUserList 方法
    },
    loadUserList() {
      console.log('开始加载用户列表');
      let page = this.$router.currentRoute.query.page;
      console.log('开始加载用户列表，页码为', page);
      if (!page) {
        page = 1;
      }
      let url = BaseUrl.ADMIN_COMPLAINT + '/admin/video/complaint/listProcessed?pageNum=' + page+'&pageSize='+this.pageSize;

      TokenAxios.get(url,page).then((response) => {
        console.log('当前页码：', this.currentPage);
        console.log('每页显示条数：', this.pageSize);
        console.log('请求 URL：', url);
        let jsonResult = response.data;
        if (jsonResult.state == 20000) {
          this.tableData = jsonResult.data.list;
          this.currentPage = jsonResult.data.currentPage;
          this.pageSize = jsonResult.data.pageSize;
          this.total = jsonResult.data.total;
          console.log('用户列表数据：', this.tableData);
          console.log('当前页码：', this.currentPage);
          console.log('每页显示条数：', this.pageSize);
          console.log('总条数：', this.total);
        } else {
          let title = '操作失败';
          this.$alert(jsonResult.message, title, {
            confirmButtonText: '确定',
            callback: action => {
            }
          })
        }
      })
    }
  },
  mounted(){
    let page = this.$route.query.page; // 通过 $route 获取当前页码
    this.loadUserList(page); // 将当前页码传递给 loadUserList 方法
  },
}
</script>


<template>
  <div>
    <!--面包屑导航区域-->
    <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-bottom: 20px;overflow: hidden">
      <el-breadcrumb-item :to="{ path: '/admin/index' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>笔记审核</el-breadcrumb-item>
      <el-breadcrumb-item>已处理</el-breadcrumb-item>
    </el-breadcrumb>


    <el-card>
      <el-table :data="tableData"
                border stripe
                style="margin-bottom: 20px;overflow: hidden">
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column
            prop="videoId"
            label="视频ID"
        >
        </el-table-column>

        <el-table-column label="文章封面" width="180" align="center" prop="url">
          <template slot-scope="scope">
            <div style="width: 115px;height: 115px;overflow: hidden;position: relative;top: 18px">
              <img :src="scope.row.url" v-if="scope.row.resourcesType !== 1" width="100%" height="100%"
                   style="object-fit: cover;">
              <video :src="scope.row.url" v-else style="object-fit: cover;width: 100%; height: 100%;"/>
            </div>
            <br>
            <el-button type="text" @click="selectImagedetail(scope.row)" style="margin-right: 55px">查看详细</el-button>
            <el-dialog
                title="文章图片"
                :visible.sync="showImagedetail"
                width="50%"
                center
                @close="handleDialogClose"
            >
              <el-row>
                <el-col span:12>
                  <el-carousel trigger="click" height="600px">
                    <el-carousel-item v-for="img in url">
                      <el-image fit="scale-down" :src="img.url" style="width: 100%; height: 100%"
                                v-show="img.resourcesType==0"/>
                      <div style="width: 600px;height: 600px;background-color: black;position: relative;left: 75px">
                        <video :src="img.url"
                               style="width: 100%;height: 100%;"
                               controls
                               autoplay
                               v-show="img.resourcesType==1"/>
                      </div>
                    </el-carousel-item>
                  </el-carousel>
                </el-col>
                <el-col span:12>
                  <p>{{ noteContent }}</p>
                </el-col>
              </el-row>
            </el-dialog>
          </template>
        </el-table-column>

        <el-table-column
            prop="complaintNumber"
            label="投诉单号"
            :show-overflow-tooltip="true"
        ></el-table-column>

        <el-table-column
            prop="ruleTypeName"
            label="违规类型"
        ></el-table-column>

        <el-table-column
            prop="content"
            label="违规内容描述"
            align="center"
            :show-overflow-tooltip="true"
        ></el-table-column>

        <el-table-column
            prop="authorName"
            label="作者昵称"
            align="center"
            :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
            prop="userName"
            label="投诉人昵称"
            align="center"
            :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
            prop="createTime"
            label="创建时间"
        >
        </el-table-column>
        <el-table-column
            prop="updateTime"
            label="修改时间"
        >
        </el-table-column>

      </el-table>
      <!--分页区域-->
      <el-pagination
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :hide-on-single-page="true"
          :page-size="pageSize"
          layout="total, prev, pager, next,jumper"
          :total="total"
          background
      >
      </el-pagination>

    </el-card>
  </div>
</template>


<style scoped>

</style>